/**
 * Copyright &copy; 2012-2016 <a href="https://www.kaaction.com">KAA</a> All rights reserved All rights reserved.
 */
package com.kaaction.modules.mer.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaaction.common.persistence.Page;
import com.kaaction.common.service.CrudService;
import com.kaaction.modules.mer.entity.OperationProductDetail;
import com.kaaction.modules.mer.dao.OperationProductDetailDao;

/**
 * 商品运营明细Service
 * @author huanghaiming
 * @version 2017-07-06
 */
@Service
@Transactional(readOnly = true)
public class OperationProductDetailService extends CrudService<OperationProductDetailDao, OperationProductDetail> {

	public OperationProductDetail get(String id) {
		return super.get(id);
	}
	
	public List<OperationProductDetail> findList(OperationProductDetail operationProductDetail) {
		return super.findList(operationProductDetail);
	}
	
	public Page<OperationProductDetail> findPage(Page<OperationProductDetail> page, OperationProductDetail operationProductDetail) {
		return super.findPage(page, operationProductDetail);
	}
	
	@Transactional(readOnly = false)
	public void save(OperationProductDetail operationProductDetail) {
		super.save(operationProductDetail);
	}
	
	@Transactional(readOnly = false)
	public void delete(OperationProductDetail operationProductDetail) {
		super.delete(operationProductDetail);
	}

	@Transactional(readOnly = false)
	public void insertOperaProDtl(String id, String opeproId) {
		
		OperationProductDetail operationProductDetail = new OperationProductDetail();
		
		String[] ids = id.split(",");
		for(String productId:ids){
			int cnt = super.dao.setCnt(productId,opeproId);
			if(cnt==0){
				operationProductDetail.setProductId(productId);
				operationProductDetail.setOpeproId(opeproId);
				operationProductDetail.preInsert();
				super.dao.insert(operationProductDetail);
			}
		
		}
		
	}

	@Transactional(readOnly = false)
	public void updateOpeProtitle(OperationProductDetail operationProductDetail) {
		super.dao.updateOpeProtitle(operationProductDetail);
	}
	
}